#include	"rdb_lib.h"

int 	CalDaemon();
int	StandardCal();
int	FormulaCal();
int	FrequencyCal();
void    KillSignalProc(int);
int	LimitCal();
int	LimitCal(int yc_id, float Val);
int	KwhCal();
int	GetHardKwhProc(TableOp* TablePtr, dd_define_scada* KwhPtr, int loop, int kwhRecNum, char* buffer);
int	GetSoftKwhProc(dd_define_scada* KwhRecPtr, float Val, char* buffer);
int	PutValBySybaseFId(struct KEY_ID_STRU*  KeyIdStr, char* ValBuf, int ValBufSize, char result_type);
void 	CTimer();
int	ZeroCopyPlanProcess();
int	CopyTomToToday();
int	Copy2DayToTom();
int	Copy3DayTo2Day();
int	Copy4DayTo3Day();
int	Copy5DayTo4Day();
int	Copy6DayTo5Day();
// Added by ZJH in SZ	00.12.13
int	Copy7DayTo6Day();
int	Copy8DayTo7Day();
// End of Added


int	GetCurPlanVal();
int	PlanSybaseSample();

int	MultiCal();
int	DWCal(calculate_source_scada* CalBufPtr);
int	IVComCal(calculate_source_scada* CalBufPtr, int	tag);


int	PldCheckGen(char type, calculate_source_scada* CalBufPtr);
int	PlBreakerOp(pld_info_scada* PldInfoPtr, TableOp* BLClass, TableOp* CBClass, int& FacID, char& CbVal1, char& CbVal2);
int	BreakerOp(pld_info_scada* PldInfoPtr, TableOp* CBClass, char BlBreakVal, char BlVal1, char BlVal2);
int	EraseYcPldResult(int device_id, char tr_pin, int FacId);
int	AddYcPldResult(int Bl_dev_id, int device_id, char tr_pin, int FacId);


//int	DdPldCheckGen();
int	GetSysFacCompId();
int	GetSysTotalAdd();
int	CompSafeDays();

int	GetSendYxVal();
int	GetSendYcVal();
int	GetSendDdVal();
void    save_sgyx_into_sybase(int yxyc_id, short field_no, int sgyx_time);
void    save_dd_into_sybase( dd_define_scada* KwhRecPtr );
int     CheckSwitchToken(int dev_id);

int	HrbPlanComp();
int     GetTotalPLimit();

int	GetPlanLimit();

int     GetValByMulti(calculate_source_scada* CalBufPtr);
int	GetSecMinTran(calculate_source_scada* CalBufPtr);
int	GetID1DivID2(calculate_source_scada* CalBufPtr);
int	GetCurveRate(calculate_source_scada* CalBufPtr);
int	GetMonthRate(calculate_source_scada* CalBufPtr, int clear_tag);
int	GetMaxMinRate(calculate_source_scada* CalBufPtr, int max_tag);

int     cq_read_interval();
int     cq_high_low_static(limit_info_scada* LimitBufPtr, float Val, int CurrentTime);
int     cq_limit_change(limit_info_scada* LimitBufPtr, int CurrentTime);

//int     PLDAddSetVal(struct pld_result_info_scada* PLDStru, short StateFieldNo);
//int     PLDRecoverSetMLVal(struct pld_result_info_scada* PLDStru, short StateFieldNo);
int     PLDAddSetVal(struct pld_result_info_scada* PLDStru);
int     PLDRecoverSetMLVal(struct pld_result_info_scada* PLDStru);
void    SendYxBwToClient( int yx_id, char yx_value );
int     MySelfIsMainServer();
int     ClearYxWarnAct();

void	GetMyHostRespArea();
void	InitWarnList();
void	WarnListProc();
char* GetTimeString(int  tmp_time, char *str, short ms);
int   GetWarnModeStr(int warn_mode, char* str1, char* str0, int str1_size, int str0_size);
void	GetYxBwMessageStr(struct yx_define_scada *yx_stru,char	*message_str,int msg_size);
void	SendOneWarnInfo(int type, int order_no,char *warn_text,int fac_id,int key_id, short field_id, int value);
void	YcWarnProc(int yc_id);
void	GetYcOverMessageStr(struct yc_define_scada* yc_stru, char *message_str,int msg_size);
